package util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author Administrator
 * @date 2024-11-06 20:06
 */
public class MD5Util {
    private MD5Util(){ }
    private static final String SALT="regerada";
    /*
    加密
     */
    public static  String encode(String str) throws NoSuchAlgorithmException {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        str+=SALT;
        messageDigest.update(str.getBytes());
        byte[] bytes = messageDigest.digest();
        BigInteger bigInteger = new BigInteger(1, bytes);
        String s1 = bigInteger.toString(16);
        String s = new String(bytes);
        return s;
    }

}
